package com.lzq.FactoryPattern;

public class Factory_Abstract {
    //抽象产品01
    interface AbstractPorduct01{
        void show();
    }
    //抽象产品02
    interface AbstractProduct02{
        void show();
    }

    //A类具体产品01
    class ConcreteprodutA_01 implements AbstractPorduct01{
        @Override
        public void show() {
            System.out.println("======生产A类具体产品01");
        }
    }
    //A类具体产品02
    class ConcreteProductA_02 implements AbstractProduct02{
        @Override
        public void show() {
            System.out.println("======生产A类具体产品02");
        }
    }

    //B类具体产品01
    class ConcreteProductB_01 implements AbstractPorduct01{
        @Override
        public void show() {
            System.out.println("=======生产B类具体产品01");
        }
    }
    //B类具体产品02
    class ConcreteProductB_02 implements AbstractProduct02{
        @Override
        public void show() {
            System.out.println("=======生产B类产具体产品02");
        }
    }

    //抽象工厂
    interface AbstractFactory{
        public AbstractPorduct01 CreConProduct01();
        public AbstractProduct02 CreConProduct02();
    }
    //具体工厂A，生产A类产品01/02
    class ConcreteFactory_A implements  AbstractFactory{
        @Override
        public AbstractPorduct01 CreConProduct01() {
            return new ConcreteprodutA_01();
        }
        @Override
        public AbstractProduct02 CreConProduct02() {
            return new ConcreteProductA_02();
        }
    }
    //具体工厂B,生产B类产品01/02
    class ConcreteFactory_B implements AbstractFactory{
        @Override
        public AbstractPorduct01 CreConProduct01() {
            return new ConcreteProductB_01();
        }
        @Override
        public AbstractProduct02 CreConProduct02() {
            return new ConcreteProductB_02();
        }
    }

    public static void main(String[] args){
        Factory_Abstract factory_abstract = new Factory_Abstract();
        AbstractFactory FactoryA = factory_abstract.new ConcreteFactory_A();
        FactoryA.CreConProduct01().show();
        FactoryA.CreConProduct02().show();
        AbstractFactory FactoryB = factory_abstract.new ConcreteFactory_B();
        FactoryB.CreConProduct01().show();
        FactoryB.CreConProduct02().show();

    }
}
